<?php
class EventNotifier extends CComponent
{
 private static $event_notifier;
 public $params;
 
 public static function setup()
 {
		if (!isset(self::$event_notifier)) {
            $c = __CLASS__;
            self::$event_notifier = new $c;
        }
		self::$event_notifier->onRegister = array(new EmailComponent, 'emailHandler');
		self::$event_notifier->onForgotPassword = array(new EmailComponent, 'emailHandler');
		self::$event_notifier->onChangePassword = array(new EmailComponent, 'emailHandler');
		return self::$event_notifier;
 }		


 public function onRegister($event)
  {
    $this->raiseEvent('onRegister', $event);
  }
  
  public function onForgotPassword($event)
  {
    $this->raiseEvent('onForgotPassword', $event);
  }
  
  public function onChangePassword($event)
  {
    $this->raiseEvent('onChangePassword', $event);
  }

 
  
  public function register($user_object)
  {
  	
  	$obj_event = new CEvent($this);
  	$param_array['email_slug'] = 'registration';
  	$param_array['object'] = $user_object;
  	$obj_event->params = $param_array;
  	$this->onRegister($obj_event);   
  }
  
  public function forgotPassword($user_object)
  {
  	
  	$obj_event = new CEvent($this);
  	$param_array['email_slug'] = 'forgot_password';
  	$param_array['object'] = $user_object;
  	$obj_event->params = $param_array;
  	$this->onForgotPassword($obj_event);  
  }
  
  public function changePassword($user_object)
  {
  	$obj_event = new CEvent($this);
  	$param_array['email_slug'] = 'change_password';
  	$param_array['object'] = $user_object;
  	$obj_event->params = $param_array;
  	$this->onChangePassword($obj_event);    		
  }
   

}